import json
from sys import argv
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm

with open("./compareTensors/3/tensor12.json", "r") as f:
    tensor1 = json.load(f)

with open("./compareTensors/3/tensor21.json", "r") as f:
    tensor2 = json.load(f)


error = np.sum(np.abs(np.array(tensor1[0]) - np.array(tensor2[0])))
print(error)

ndarray1 = np.array(tensor1)
ndarray2 = np.array(tensor2)

tensor_a = ndarray1[0][0]
tensor_b = ndarray2[1][0]

error = np.abs(tensor_a - tensor_b)

x = np.linspace(0, tensor_a.shape[1] - 1, tensor_a.shape[1])
y = np.linspace(0, tensor_a.shape[0] - 1, tensor_a.shape[0])
x_mesh, y_mesh = np.meshgrid(x, y)
fig = plt.figure()
ax = fig.add_axes(Axes3D(fig))
surf = ax.plot_surface(x_mesh, y_mesh, error, cmap=cm.coolwarm, linewidth=0, antialiased=False)
plt.show()
